﻿/*************************************************************************
 *  Copyright (C), 2017-2018, YangTao tech. Co., Ltd.
 *  FileName: PreDefScrp.cs
 *  Author: YangTao   Version: 1.0   Date: 2/9/2017
 *  Email:YangTao_Unity3D@163.com
 *  Version Description:
 *    用于命令类消息的生成管理。
 *  File Description:
 *    
 *  Class List:
 *    <ID>           <name>             <description>
 *     1.         PreDefScrp             
 *  Function List:
 *    <ID>           <name>             <description>
 *     1. 
 *  History:
 *    <ID>    <author>      <time>      <version>      <description>
 *     1.     YangTao     2/9/2017       1.0        Build this file.
 *************************************************************************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public delegate void Void_StringDelegate(string str);
public delegate void Void_StringStringDelegate(string str1, string str2);
public delegate void Void_ListStringDelegate(List<string> list);
public delegate void Void_IntStringDelegate(int i, string str);
public delegate void Void_StringStringStrListDelegate(string str1, string str2, List<string> list);
public delegate void Void_BoolDelegate(bool b);
public delegate void Void_IntDelegate(int i);
public delegate void Void_Delegate();

public class PreDefScrp 
{
    /// <summary>
    /// List深拷贝
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="listFrom">被拷贝List</param>
    /// <param name="listTo">拷贝到的List</param>
    public static void ListDeepCopy<T>(List<T> listFrom, out List<T> listTo) where T : IComparable
    {
        if (listFrom == null)
        {
            listTo = null;
            return;
        }

        listTo = new List<T>();
        for (int i = 0; i < listFrom.Count; i++)
        {
            listTo.Add(listFrom[i]);
        }
    }

    /// <summary>
    /// List尾部增加
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="listFrom">被拷贝List</param>
    /// <param name="listTo">拷贝到的List</param>
    public static void ListAddTo<T>(List<T> listFrom, ref List<T> listTo) where T : IComparable
    {
        if (listFrom == null)
        {
            return;
        }

        for (int i = 0; i < listFrom.Count; i++)
        {
            listTo.Add(listFrom[i]);
        }
    }

    public static void ListRemove<T>(List<T> removeList, ref List<T> list) where T : IComparable
    {
        if (removeList == null)
        {
            return;
        }

        for (int i = 0; i < removeList.Count; i++)
        {
            list.Remove(removeList[i]);
        }
    }
}
